home *** CD-ROM | disk | FTP | other *** search
- /*
-
- $VER: MM_FindPirates 1.1 (06/06/98)
-
- Copyright ©1998 Neil Williams
-
- now2@frost3.demon.co.uk, 2:442/107.0@fidonet, 39:136/1.0@amiganet
- neil@bleach.demon.co.uk
-
- */
-
- parse arg args
-
- options cache
- options failat 99
- options results
-
- signal on break_c
- signal on break_d
- signal on break_e
- signal on break_f
- signal on halt
- signal on ioerr
- signal on syntax
-
- address 'MAILMANAGER'
-
-
- Main:
-
- call Init
- call Header
- call Read_Cfg
- call Wait_AreasWindow
-
- call CheckAreas
-
- call Quit(0, 'All done.')
- exit
-
-
- break_c:; break_d:; break_e:; break_f:; halt:
-
- signal off break_c
- signal off break_d
- signal off break_e
- signal off break_f
- signal off halt
-
- return_code = 5
- error_line = 0
- error_msg = 'Execution halted!!!'
- rc = 0
- signal Exit
-
-
- Exit:
-
- select
- when return_code>=40 then error = 'INTERNAL-ERROR:'
- when return_code>=30 then error = 'IO-ERROR:'
- when return_code>=20 then error = 'ERROR:'
- when return_code>=10 then error = 'WARNING:'
- when return_code>=5 then error = 'INFO:'
- otherwise error = ''
- end
-
- call Log()
- call Log('***' strip(error error_msg) '***', '+')
- call Log(,'\')
-
- call setclip('MM_LogPre', system.mm.logpre)
-
- exit return_code
-
-
-
- Wait_AreasWindow: procedure Expose system.
-
- MM_AreasWin
- if rc=0 then return
-
- bell = '07'x
- cr = '0D'x
-
- if Request_Choice('\c\n\1'system.prg.id'\0 is waiting.\n\nPlease go back to the Areas-Window as soon as possible!\n',,
- '* _WAIT | _QUIT ', '0 1') then call Quit(5, 'Aborted by user.')
-
- tmp = 'Waiting for Areas-Window...'
- call writech(STDOUT, bell || tmp || cr)
- call Log(tmp,, 4)
-
- rc = 1
-
- do while rc~=0
- MM_AreasWin
-
- call writech(STDOUT, bell)
- call Delay(250)
- end
-
- return
-
-
- Request_Choice: procedure Expose system.
-
- parse arg text, buttons, ret_vals
-
- title = system.prg.name'-Requester'
- text = translate(Replace(text, '0A'x, '\n'), '1b'x, '\')
-
- if length(text)<40 then text = center(text, 40)
-
- MM_Requester title 'text' 'buttons'
-
- if rc=0 then rc=words(ret_vals)
-
- return compress(word(ret_vals, rc), '_')
-
-
- Get_Arg: procedure Expose args system.
-
- arg keyword, mode, old
-
- uargs = upper(args)
- p = find(uargs, keyword)
-
- if p=0 then
- do
- p = pos(' 'keyword'=', ' 'uargs)
-
- if p>0 then args = overlay(' ', args, p+length(keyword))
-
- p = find(upper(args), keyword)
- end
-
- system.cmdopt.keyword = p>0
-
- select
- when mode=0 then
- if p>0 then
- do
- ret = 1
- args = delword(args, p, 1)
- end
- else ret = old
-
- when mode=1 then
- if p>0 then
- do
- left = subword(args, 1, p-1)
- rest = subword(args, p+1)
-
- if left(rest, 1)='"' then parse var rest . '"' ret '"' rest
- else parse var rest ret rest
-
- args = strip(left strip(rest))
- end
- else ret = old
-
- when mode=2 then
- do
- if left(args, 1)='"' then parse var args . '"' ret '"' args
- else parse var args ret args
-
- if strip(ret)='' then ret = old
- end
-
- otherwise exit 99
- end
-
- args = strip(args)
- ret = strip(ret, 'b', '" ')
-
- return ret
-
-
- Get_Version: procedure
-
- parse arg mode
-
- parse value sourceline(3-mode) with . . ver .
- parse var ver tst 'ß' .
-
- if ~datatype(strip(tst, 'b', '/c '), 'N') then
- if ~mode then ver = Get_Version(1)
- else exit 99
-
- return ver
-
-
- Header:
-
- call Log(,'/')
- call Log('***' system.prg.id '***', '+')
- call Log(' 'system.prg.cr)
- call Log()
-
- return
-
-
- Init:
-
- system. = 0
-
- system.prg.ver = Get_Version(0)
- system.prg.name = 'MM_FindPirates'
- system.prg.id = system.prg.name 'v'system.prg.ver
- system.prg.cfg = 'MM:Config/'system.prg.name'.cfg'
- system.prg.cr = '(c)1998 Neil Williams'
- system.tmpfile = 'T:'system.prg.name'.tmp'
- system.mm.logpre = getclip('MM_LogPre')
- system.prg.logpre = system.mm.logpre'|'
- system.prg.loglevel = 2
- call setclip('MM_LogPre', system.prg.logpre)
- /* system.cmdopts = 'OPTIONS' */
-
- system.config.areas.total = 0
- system.config.foot.total = 0
- system.config.head.total = 0
- system.config.allareas = 0
-
- call Include_Lib('rexxsupport')
- return
-
-
- Include_Lib: procedure Expose system.
-
- parse arg lib, prio
- if right(upper(lib), 8)~='.LIBRARY' then lib = lib'.library'
- if prio='' then prio = 0
-
- if ~show('l', lib) then
- if ~addlib(lib, prio, -30, 0) then call Quit(20, 'Could not open' lib'!!!')
-
- return
-
-
- IOerr:
-
- signal off ioerr
-
- return_code = 20
- error_line = sigl
- error_msg = 'IO-error' rc 'at line' sigl '['errortext(rc)']')
- rc = 0
- signal Exit
-
-
- Log: procedure Expose system.
-
- parse arg text, pre, level
-
- if ~datatype(level, 'N') then level = system.prg.loglevel
-
- tmp = word('PRG MM', (pre~='')+1)
- text = system.tmp.logpre || pre' 'text
-
- MM_WriteLog 'text' level
- return
-
-
-
-
- Quit:
-
- parse arg return_code, error_msg
-
- error_line = 0
- rc = 0
- signal Exit
-
-
- Read_Cfg: procedure Expose system.
-
- MM_ReadStem system.prg.cfg 'cfg'
- if RC~=0 then call Quit(31, 'Unable to read' system.prg.cfg'!!!')
-
- call Log('Reading config...')
-
- cnt = 0
-
- do l=0 to cfg.count-1
- parse value strip(translate(cfg.l, ' ', '9'x)) with key args ';' .
- key = upper(strip(key))
- args = strip(args)
-
- select
- when key='' then iterate
-
- when key='#ALLAREAS' then system.config.allareas = 1
-
- when key='#AREA' then call Add_Area( args )
- when key='#FOOTER' then call Add_Foot( args )
- when key='#HEADER' then call Add_Head( args )
-
- otherwise say '*** CFG-ERROR: Unknown keword "'key'" at line' l'!!!'
- end
-
- cnt = cnt+1
- end
-
- return
-
-
- /* add an area to search
- */
- Add_Area: procedure Expose system.
-
- parse arg area
-
- i = system.config.areas.total
- system.config.areas.i = area
- system.config.areas.total = system.config.areas.total+1
-
- return
-
-
- /* add a line to look for in the footer of the msg
- */
- Add_Foot: procedure Expose system.
-
- parse arg txt
-
- i = system.config.foot.total
- system.config.foot.i = txt
- system.config.foot.total = system.config.foot.total+1
-
- return
-
-
- /* add a line to look for in the kludges/header
- */
- Add_Head: procedure Expose system.
-
- parse arg txt
-
- i = system.config.head.total
- system.config.head.i = txt
- system.config.head.total = system.config.head.total+1
-
- return
-
-
-
- Replace: procedure
-
- parse arg string, new, old
-
- do while index(string, old) ~= 0
- interpret "parse var string l '"old"' r"
- string = l || new || r
- end
-
- return string
-
-
- Syntax:
-
- signal off syntax
-
- return_code = 40
- error_line = sigl
- error_msg = 'Syntax-error' rc 'at line' sigl '['errortext(rc)']'
- rc = 0
- signal Exit
-
-
- Usage:
-
- rx. = ''
- rx.0.0 = '[rx] '
- rx.0.1 = '[.rexx]'
- m = pos('/e', system.prg.ver)>0
-
- say
- say 'Usage:' rx.m.0 || system.prg.name || rx.m.1 system.cmdopts
- say
- call Quit(0, 'Usage requested.')
-
-
- CheckAreas: procedure Expose system.
-
- /* trace ?all */
-
- do i = 0 to system.config.areas.total-1
-
- MM_SearchMsgs system.config.areas.i 'msgs' '#?' '#?' '#?' '!SENT'
-
- if RC = 0 then do
-
- do j = 0 to msgs.count-1
-
- MM_ReadMsg system.config.areas.i msgs.j 'readmsg'
-
- foundf.count = 0
- foundh.count = 0
-
- do k = 0 to readmsg.foot.count
- if left( readmsg.foot.k, 1 ) = '1'x then do
- readmsg.foot.k = right( readmsg.foot.k, length( readmsg.foot.k )-1 )
- end
- end
-
- do k = 0 to readmsg.head.count
- if left( readmsg.head.k, 1 ) = '1'x then do
- readmsg.head.k = right( readmsg.head.k, length( readmsg.head.k )-1 )
- end
- end
-
- if system.config.foot.total ~= 0 then do
- do k = 0 to system.config.foot.total-1
- MM_SearchInStem readmsg.foot 'foundf' '"'system.config.foot.k'"' 'STR'
- end
- end
-
- if system.config.head.total ~= 0 then do
- do k = 0 to system.config.head.total-1
- MM_SearchInStem readmsg.head 'foundh' '"'system.config.head.k'"' 'STR'
- end
- end
-
- /* found any? the counts will be greater than 0 if we have */
- if ( (foundf.count > 0) | (foundh.count > 0) ) then do
-
- boss = FindBoss( readmsg.fromaddr )
-
- call Log( 'Found a pirate!' )
- call Log( ' Area: 'system.config.areas.i' Msg Nº: 'msgs.j )
- call Log( ' From: 'readmsg.from' <'readmsg.fromaddr'> Boss: 'boss )
-
- MM_GetNodelistNode boss 'nodestem'
-
- /* this needs to be put into the config file, with % codes for features */
-
- drop outmsg.
-
- outmsg.0 = 'Hello '|| nodestem.sysop ||','
- outmsg.1 = ''
- outmsg.2 = 'This is an automatically generated message. It would appear'
- outmsg.3 = 'that a system which is under your responsibility is using'
- outmsg.4 = 'pirated software. This is illegal, immoral and violates both'
- outmsg.5 = 'FidoNet and AmigaNet policy. The evidence is included below,'
- outmsg.6 = 'with the important lines highlighted. The actual message has'
- outmsg.7 = 'been trucated to 20 lines.'
- outmsg.8 = ''
- outmsg.9 = 'Author: 'readmsg.from ' ' readmsg.fromaddr
- outmsg.10 = 'Addressee: 'readmsg.to
- outmsg.11 = 'Subject: 'readmsg.subj
- outmsg.12 = 'Area: 'system.config.areas.i
- outmsg.13 = 'Date: 'readmsg.date
- outmsg.14 = ''
- outmsg.15 = '-------------- BEGINNING OF INCLUDED MESSAGE ---------------'
- outmsg.count = 16
-
- MM_WriteStem system.tmpfile outmsg
- MM_WriteStem system.tmpfile readmsg.head APPEND
-
- if readmsg.text.count > 20-1 then do
- readmsg.text.count = 20
- alt = 1
- end
- else alt = 0
-
- MM_WriteStem system.tmpfile readmsg.text APPEND
-
- if alt = 1 then do
- outmsg.0 = ''
- outmsg.1 = '[...]'
- outmsg.2 = ''
- outmsg.count = 3
-
- MM_WriteStem system.tmpfile outmsg APPEND
- end
-
- MM_WriteStem system.tmpfile readmsg.foot APPEND
-
- outmsg.0 = '----------------- END OF INCLUDED MESSAGE ------------------'
- outmsg.1 = ''
- outmsg.count = 2
- MM_WriteStem system.tmpfile outmsg APPEND
-
- outmsg.0 = '----------- BEGINNING OF ANALYSED RELEVANT DATA -------------'
- outmsg.count = 1
- MM_WriteStem system.tmpfile outmsg APPEND
-
- MM_WriteStem system.tmpfile foundh APPEND
- MM_WriteStem system.tmpfile foundf APPEND
-
- outmsg.0 = '-------------- END OF ANALYSED RELEVANT DATA ----------------'
- outmsg.1 = ''
- outmsg.count = 2
- MM_WriteStem system.tmpfile outmsg APPEND
-
- MM_GetNearestAddr boss myaddr
-
- matrix = Get_MailArea( boss )
-
- wmsg.from = system.prg.name
- wmsg.fromaddr = myaddr
- wmsg.to = nodestem.sysop
- wmsg.toaddr = boss
- wmsg.subj = 'URGENT! Illegal activities!'
- wmsg.flags = 'PVT RRR'
- wmsg.file = system.tmpfile
-
- MM_WriteMsg matrix wmsg
-
- end /* if found pirate */
-
- end /* do j msgs */
-
- end /* if RC = 0 */
- else do
- call Log( 'Unknown area '|| system.config.areas.i )
- end
-
- end /* do i areas */
-
- return
-
-
- /* This was writen by Tomasz Nidecki - it finds either the boss node of a point
- * or the NC of the net a SysOp (point = 0) is in.
- */
-
- FindBoss: PROCEDURE
-
- PARSE ARG zone ':' net '/' node '.' point '@' domain
-
- IF point ~= '0' THEN
- DO
- BossNode = zone':'net'/'node'.0@'domain
- END
- ELSE
- DO
- BossNode = zone':'net'/0.0@'domain
- END
-
- RETURN BossNode
-
-
-
- /* This was taken from MM_Flame.rexx
- * It tried to match an address to a MATRIX/Netmail area.
- */
- Get_MailArea: procedure Expose system.
-
- arg . '@' domain
-
- MM_GetAreas 'tmp' 'MAIL'
-
- do n=0 to tmp.count-1
- MM_GetAreaInfo tmp.n 'info'
- parse value upper(info.addr) with . '@' dmn
-
- if domain=dmn then return tmp.n
- end
-
- return tmp.0
-